/**
 * Created by wzh on 2016/7/2.
 */
'use strict';
swan_pc
    .factory('CompanyInfo', function ($resource, DateUtils) {
        return $resource('/api/userCompanys/:infoid', {infoid:'@infoid'}, {
            'query': { method: 'GET', isArray: true,
                transformRequest: function (item) {
                    _.forEach(item,function(data){
                        data.companyBaseInfo.foundDate = new Date(data.companyBaseInfo.foundDate);
                    });
                    return angular.toJson(item);
                }
            },
            'queryAll': {
                method: 'GET',
                isArray:true,
                url:"/api/userCompanys/all",
                transformRequest: function (item) {
                    _.forEach(item,function(data){
                        data.companyBaseInfo.foundDate = new Date(data.companyBaseInfo.foundDate);
                    });
                    return angular.toJson(item);
                }
            },
            'update': {
                method: 'PUT',
                // transformRequest: function (data) {
                //     data.companyBaseInfo.foundDate = DateUtils.convertLocaleDateToServer(data.companyBaseInfo.foundDate);
                //     return angular.toJson(data);
                // }
            },
            'save': {
                method: 'POST',
                // transformRequest: function (data) {
                //     //data.birthDate = DateUtils.convertLocaleDateToServer(data.birthDate);
                //     return angular.toJson(data);
                // }
            },
            'delete':{
                method:'DELETE'
            },
            'linkup':{
                method:'GET',
                url:"/api/userCompanys/:infoid/linkUp",
            },
            'linkDown':{
                method:'GET',
                url:"/api/userCompanys/linkDown",
            },
            'breakLink':{
                method:'GET',
                url:"/api/userCompanys/:infoid/breakDownByUser",
            },
            "queryList":{
                method:"GET",
                isArray:true,
                url:"/api/userCompanys/list"
            }
        });
    });